package com.mofeng.myshop.domain.vo.user;

import com.mofeng.myshop.domain.po.UserPower;
import com.mofeng.myshop.domain.vo.base.BaseVo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class UserPowerVo extends BaseVo {
    @Schema(description = "权限码值")
    private Integer number;

    public UserPowerVo(UserPower user) {
        super(user);
        this.number = user.getNumber();
    }

    public static List<UserPowerVo> change(Collection<UserPower> userPowers) {
        if (userPowers == null || userPowers.isEmpty()) {
            return new ArrayList<>();
        }
        return userPowers.stream().map(UserPowerVo::new).toList();
    }
}
